package com.jh3502.vivo.function.travelnew;

import android.content.Context;

import com.google.gson.Gson;
import com.jh3502.vivo.base.BaseJson;
import com.jh3502.vivo.base.BaseModel;
import com.jh3502.vivo.net.ApiClient;
import com.jh3502.vivo.net.ApiConstants;
import com.jh3502.vivo.utils.SpHelper;
import com.jh3502.vivo.utils.UploadHelper;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import retrofit2.Callback;

/**
 * @author harisucici
 * @date 2017/6/19
 */

public class TravelNewModel extends BaseModel {

    public TravelNewModel(Context context) {
        super(context);
    }

    public void sumtravel(Map<String, Object> body, Callback<BaseJson> callback) {
        Map<String, Object> bodyMain = new HashMap<>(2);
        bodyMain.put("json", new Gson().toJson(body));
        mCall = ApiClient.apiList.sumtravel(SpHelper.getInstance().getToken(), bodyMain);
        mCall.enqueue(callback);
    }

    public void getTravelById(Map<String, Object> body, Callback<BaseJson> callback) {
        Map<String, Object> bodyMain = new HashMap<>(2);
        bodyMain.put("json", new Gson().toJson(body));
        mCall = ApiClient.apiList.getTravelById(SpHelper.getInstance().getToken(), bodyMain);
        mCall.enqueue(callback);
    }

    public void upload(List<File> files, okhttp3.Callback callback) {
        UploadHelper.uploadImage(files, ApiConstants.getUploadImageUrl(), callback);
    }
}
